home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / crt0.s < prev    next >
Text File  |  1992-03-17  |  2KB  |  65 lines

  1. |
  2. | Initilization code; this is common to both 16 and 32 bit libraries,
  3. | so be careful!
  4. |
  5.     .globl    __app        | short, declared in crtinit.c
  6.     .globl    __base        | BASEPAGE *, declared in crtinit.c
  7.     .globl    __heapbase    | void *
  8.     .globl    __stksize    | long, declared by user or in stack.c
  9.  
  10. |
  11. | Assumption: basepage is passed in a0 for accessories; for programs
  12. | a0 is always 0.
  13.  
  14.     .text
  15.     .even
  16.     .globl    __start
  17. __start:
  18.     subl    a6, a6        | clear a6 for debuggers
  19.     cmpw    #0, a0        | test if acc or program
  20.     beq    __startprg    | if a program, go elsewhere
  21.     tstl    a0@(36)        | also test parent basepage pointer
  22.     bne    __startprg    | for acc's, it must be 0
  23.     movel    a0, __base    | acc basepage is in A0
  24.     lea    a0@(252), sp    | use the command line as a temporary stack
  25.     jmp    __acc_main    | function is in crtinit.c
  26. |
  27. | program startup code: doesn't actually do much, other than push
  28. | the basepage onto the stack and call _start1 in crtinit.c
  29. |
  30. __startprg:
  31.     movel    sp@(4), a0    | get basepage
  32.     movel    a0, __base    | save it
  33.     movel    a0@(4), d0    | get _base->p_hitpa
  34.     andl    #0xfffffffe, d0    | round off
  35.     movel    d0, sp        | set stack (temporarily)
  36.     jmp    __crtinit    | in crtinit.c
  37.  
  38. |
  39. | _setstack: changes the stack pointer; called as
  40. |     void setstack( void *newsp )
  41. | called from crtinit.c once the new stack size has been decided upon
  42. |
  43. | WARNING WARNING WARNING: after you do this, local variables may no longer
  44. | be accessible!
  45. | destroys a0 and a7
  46.  
  47.     .globl    __setstack
  48. __setstack:
  49.     movel    sp@+, a0    | save return address
  50.     movel    sp@+, sp    | new stack pointer
  51.     subql    #4, sp        | fixup for tidy upon return
  52.     jmp    a0@        | back to caller
  53.  
  54. |
  55. | interfaces for gprof: for crt0.s, does nothing, but for gcrt0.s branches
  56. | to the appropriate subroutines
  57. |
  58.     .globl     __monstartup
  59.     .globl    __moncontrol
  60.     .globl     ___mcleanup
  61. __monstartup:
  62. __moncontrol:
  63. ___mcleanup:
  64.     rts
  65.